package com.xqls.quaz;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Callable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.xqls.bean.DischargeRealdataBean;
import com.xqls.bean.IntakeRealdataBean;
import com.xqls.bean.PublicStormwaterRealdataBean;
import com.xqls.bean.RainwaterDischargeRealdataBean;
import com.xqls.biz.AlarmBiz;
import com.xqls.dal.model.Dictionary;
import com.xqls.service.AlarmService;
import com.xqls.service.CompanyService;
import com.xqls.service.DictionaryService;
import com.xqls.service.DischargeRealdataService;
import com.xqls.service.IntakeRealdataService;
import com.xqls.service.PublicStormwaterRealdataService;
import com.xqls.service.RainwaterDischargeRealdataService;
import com.xqls.util.ContextUtil;
import com.xqls.util.DictionaryEnums;

@Service
public class AlarmMessageRunAble  {
	private String deviceType;

	public AlarmMessageRunAble(  String deviceType) {
		this.deviceType = deviceType;
	}

	private static final Logger LOG = LoggerFactory.getLogger(AlarmMessageRunAble.class);
	IntakeRealdataService intakeRealdataService = (IntakeRealdataService) ContextUtil
			.getBean(IntakeRealdataService.class);
	DischargeRealdataService dischargeRealdataService = (DischargeRealdataService) ContextUtil
			.getBean(DischargeRealdataService.class);
	RainwaterDischargeRealdataService rainService = (RainwaterDischargeRealdataService) ContextUtil
			.getBean(RainwaterDischargeRealdataService.class);
	PublicStormwaterRealdataService publicService = (PublicStormwaterRealdataService) ContextUtil
			.getBean(PublicStormwaterRealdataService.class);
	CompanyService companyService = (CompanyService) ContextUtil.getBean(CompanyService.class);
	AlarmBiz alarmBiz = (AlarmBiz) ContextUtil.getBean(AlarmBiz.class);

	public Void call() {

		try {
			Map<String, Object> maps = selTypeInSelect();
			List<Integer> modularlist = transferStringToList(deviceType);// 自定义设备类型；取水口，排放口，企业雨水，公共雨水
			List<IntakeRealdataBean> list1 = new ArrayList<IntakeRealdataBean>();// 取水口集合
			List<DischargeRealdataBean> list2 = new ArrayList<DischargeRealdataBean>();// 排放口集合
			List<RainwaterDischargeRealdataBean> list3 = new ArrayList<RainwaterDischargeRealdataBean>();// 企业雨水排放口集合
			List<PublicStormwaterRealdataBean> list4 = new ArrayList<PublicStormwaterRealdataBean>();// 公共雨水排放口集合
			if (maps != null && maps.size() > 0) {
				for (int i = 0; i < modularlist.size(); i++) {
					if (modularlist.get(i) == 2) {// 取水口
						if ((maps.get("powerSupply") != null && maps.get("powerSupply") != "")
								|| (maps.get("netWork") != null && maps.get("netWork") != "")) {
							list1 = selMapInRealData(maps);
						}
					} else if (modularlist.get(i) == 3) {// 排放口
						if ((maps.get("powerSupply") != null && maps.get("powerSupply") != "")
								|| (maps.get("netWork") != null && maps.get("netWork") != "")
								|| (maps.get("instrument") != null && maps.get("instrument") != "")
								|| (maps.get("valveSetting") != null && maps.get("valveSetting") != "")) {
							list2 = selMapDrainInRealData(maps);
						}
					} else if (modularlist.get(i) == 4) {// 企业雨水
						if ((maps.get("powerSupply") != null && maps.get("powerSupply") != "")
								|| (maps.get("netWork") != null && maps.get("netWork") != "")
								|| (maps.get("instrument") != null && maps.get("instrument") != "")
								|| (maps.get("drain") != null && maps.get("drain") != "")) {
							list3 = selMapEnterpriseInRealData(maps);
						}
					} else if (modularlist.get(i) == 5) {// 公共雨水
						if ((maps.get("powerSupply") != null && maps.get("powerSupply") != "")
								|| (maps.get("netWork") != null && maps.get("netWork") != "")
								|| (maps.get("instrument") != null && maps.get("instrument") != "")) {
							list4 = selMapPublicInRealData(maps);
						}
					}
				}

				if (list1 != null && list1.size() > 0) {
					for (IntakeRealdataBean intakeRealdataBean : list1) {
						if (intakeRealdataBean.getNetwork() != null && intakeRealdataBean.getNetwork() != ""
								&& "离线".equals(intakeRealdataBean.getNetwork()) && intakeRealdataBean.getDeviceNo() != null
								&& intakeRealdataBean.getDeviceNo() != "") {
							alarmBiz.sendMessage(intakeRealdataBean.getDeviceNo(), DictionaryEnums.NETWORK_OFFLINE.getCode(),
									DictionaryEnums.ALARM);
						}
						if (intakeRealdataBean.getPowerSupply() != null && intakeRealdataBean.getPowerSupply() != ""
								&& "异常".equals(intakeRealdataBean.getPowerSupply())
								&& intakeRealdataBean.getDeviceNo() != null && intakeRealdataBean.getDeviceNo() != "") {
							alarmBiz.sendMessage(intakeRealdataBean.getDeviceNo(), DictionaryEnums.POWER_ANOMALY.getCode(),
									DictionaryEnums.ALARM);
						}

					}
				}
				if (list2 != null && list2.size() > 0) {
					for (DischargeRealdataBean dischargeRealdataBean : list2) {
						if (dischargeRealdataBean.getNetwork() != null && dischargeRealdataBean.getNetwork() != ""
								&& "离线".equals(dischargeRealdataBean.getNetwork())
								&& dischargeRealdataBean.getDeviceNo() != null
								&& dischargeRealdataBean.getDeviceNo() != "") {
							alarmBiz.sendMessage(dischargeRealdataBean.getDeviceNo(), DictionaryEnums.NETWORK_OFFLINE.getCode(),
									DictionaryEnums.ALARM);
						}
						if (dischargeRealdataBean.getPowerSupply() != null && dischargeRealdataBean.getPowerSupply() != ""
								&& "异常".equals(dischargeRealdataBean.getPowerSupply())
								&& dischargeRealdataBean.getDeviceNo() != null
								&& dischargeRealdataBean.getDeviceNo() != "") {
							alarmBiz.sendMessage(dischargeRealdataBean.getDeviceNo(), DictionaryEnums.POWER_ANOMALY.getCode(),
									DictionaryEnums.ALARM);
						}
						if (dischargeRealdataBean.getInstrument() != null && dischargeRealdataBean.getInstrument() != ""
								&& "开".equals(dischargeRealdataBean.getInstrument())
								&& dischargeRealdataBean.getDeviceNo() != null
								&& dischargeRealdataBean.getDeviceNo() != "") {
							alarmBiz.sendMessage(dischargeRealdataBean.getDeviceNo(), DictionaryEnums.DOOR_OPEN.getCode(),
									DictionaryEnums.ALARM);
						}
						if (dischargeRealdataBean.getDrainLevel() != null
								&& dischargeRealdataBean.getDrainLevel() != ""
								&& "异常".equals(dischargeRealdataBean.getDrainLevel())
								&& dischargeRealdataBean.getDeviceNo() != null
								&& dischargeRealdataBean.getDeviceNo() != "") {
							alarmBiz.sendMessage(dischargeRealdataBean.getDeviceNo(),
									DictionaryEnums.LEVEL_ANOMALY.getCode(), DictionaryEnums.ALARM);
						}
						if (dischargeRealdataBean.getValveState() != null && dischargeRealdataBean.getValveState() != ""
								&& dischargeRealdataBean.getValveSetting() != null
								&& dischargeRealdataBean.getValveSetting() != ""
								&& ((Integer.parseInt(dischargeRealdataBean.getValveState())
								- Integer.parseInt(dischargeRealdataBean.getValveSetting())) < -10
								|| (Integer.parseInt(dischargeRealdataBean.getValveState())
								- Integer.parseInt(dischargeRealdataBean.getValveSetting())) > 10)
								&& dischargeRealdataBean.getDeviceNo() != null
								&& dischargeRealdataBean.getDeviceNo() != "") {
							alarmBiz.sendMessage(dischargeRealdataBean.getDeviceNo(), DictionaryEnums.VALVE_FAILURE.getCode(),
									DictionaryEnums.ALARM);
						}

					}
				}
				if (list3 != null && list3.size() > 0) {
					for (RainwaterDischargeRealdataBean rainwaterDischargeRealdataBean : list3) {
						if (rainwaterDischargeRealdataBean.getNetwork() != null
								&& rainwaterDischargeRealdataBean.getNetwork() != ""
								&& "离线".equals(rainwaterDischargeRealdataBean.getNetwork())
								&& rainwaterDischargeRealdataBean.getDeviceNo() != null
								&& rainwaterDischargeRealdataBean.getDeviceNo() != "") {
							alarmBiz.sendMessage(rainwaterDischargeRealdataBean.getDeviceNo(),
									DictionaryEnums.NETWORK_OFFLINE.getCode(), DictionaryEnums.ALARM);
						}
						if (rainwaterDischargeRealdataBean.getPowerSupply() != null
								&& rainwaterDischargeRealdataBean.getPowerSupply() != ""
								&& "异常".equals(rainwaterDischargeRealdataBean.getPowerSupply())
								&& rainwaterDischargeRealdataBean.getDeviceNo() != null
								&& rainwaterDischargeRealdataBean.getDeviceNo() != "") {
							alarmBiz.sendMessage(rainwaterDischargeRealdataBean.getDeviceNo(),
									DictionaryEnums.POWER_ANOMALY.getCode(), DictionaryEnums.ALARM);
						}
						if (rainwaterDischargeRealdataBean.getInstrument() != null
								&& rainwaterDischargeRealdataBean.getInstrument() != ""
								&& "开".equals(rainwaterDischargeRealdataBean.getInstrument())
								&& rainwaterDischargeRealdataBean.getDeviceNo() != null
								&& rainwaterDischargeRealdataBean.getDeviceNo() != "") {
							alarmBiz.sendMessage(rainwaterDischargeRealdataBean.getDeviceNo(),
									DictionaryEnums.DOOR_OPEN.getCode(), DictionaryEnums.ALARM);
						}
						if (rainwaterDischargeRealdataBean.getDrainLevel() != null
								&& rainwaterDischargeRealdataBean.getDrainLevel() != ""
								&& "异常".equals(rainwaterDischargeRealdataBean.getDrainLevel())
								&& rainwaterDischargeRealdataBean.getDeviceNo() != null
								&& rainwaterDischargeRealdataBean.getDeviceNo() != "") {
							alarmBiz.sendMessage(rainwaterDischargeRealdataBean.getDeviceNo(),
									DictionaryEnums.LEVEL_ANOMALY.getCode(), DictionaryEnums.ALARM);
						}
						if (rainwaterDischargeRealdataBean.getValveRealtime() != null && rainwaterDischargeRealdataBean.getValveRealtime() != ""
								&& rainwaterDischargeRealdataBean.getValveSetting() != null
								&& rainwaterDischargeRealdataBean.getValveSetting() != ""
								&& !rainwaterDischargeRealdataBean.getValveRealtime().equals(rainwaterDischargeRealdataBean.getValveSetting())
								&& rainwaterDischargeRealdataBean.getDeviceNo() != null
								&& rainwaterDischargeRealdataBean.getDeviceNo() != "") {
							alarmBiz.sendMessage(rainwaterDischargeRealdataBean.getDeviceNo(), DictionaryEnums.VALVE_FAILURE.getCode(),
									DictionaryEnums.ALARM);
						}

					}
				}
				if (list4 != null && list4.size() > 0) {
					for (PublicStormwaterRealdataBean publicStormwaterRealdataBean : list4) {
						if (publicStormwaterRealdataBean.getNetwork() != null
								&& publicStormwaterRealdataBean.getNetwork() != ""
								&& "离线".equals(publicStormwaterRealdataBean.getNetwork())
								&& publicStormwaterRealdataBean.getDeviceNo() != null
								&& publicStormwaterRealdataBean.getDeviceNo() != "") {
							alarmBiz.sendMessage(publicStormwaterRealdataBean.getDeviceNo(),
									DictionaryEnums.NETWORK_OFFLINE.getCode(), DictionaryEnums.ALARM);
						}
						if (publicStormwaterRealdataBean.getPowerSupply() != null
								&& publicStormwaterRealdataBean.getPowerSupply() != ""
								&& "异常".equals(publicStormwaterRealdataBean.getPowerSupply())
								&& publicStormwaterRealdataBean.getDeviceNo() != null
								&& publicStormwaterRealdataBean.getDeviceNo() != "") {
							alarmBiz.sendMessage(publicStormwaterRealdataBean.getDeviceNo(),
									DictionaryEnums.POWER_ANOMALY.getCode(), DictionaryEnums.ALARM);
						}
						if (publicStormwaterRealdataBean.getInstrument() != null
								&& publicStormwaterRealdataBean.getInstrument() != ""
								&& "开".equals(publicStormwaterRealdataBean.getInstrument())
								&& publicStormwaterRealdataBean.getDeviceNo() != null
								&& publicStormwaterRealdataBean.getDeviceNo() != "") {
							alarmBiz.sendMessage(publicStormwaterRealdataBean.getDeviceNo(), DictionaryEnums.DOOR_OPEN.getCode(),
									DictionaryEnums.ALARM);
						}

					}
				}
				List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>();
				mapList = selAlarmWithAlarm(maps);// 查询报警表中报警的信息
				if (mapList != null && mapList.size() > 0) {
					for (Map<String, Object> map : mapList) {
						if (map.get("deviceType") != null && map.get("deviceType") != "") {
							if (Integer.parseInt(map.get("deviceType").toString()) == DictionaryEnums.INTAKE.getCode()) {
								IntakeRealdataBean intakeRealdataBean = intakeRealdataService
										.queryByDeviceNo(map.get("deviceNo").toString());
								if(intakeRealdataBean!=null){
									noAlarm(map, intakeRealdataBean, null, null, null);
								}
							}
							if (Integer.parseInt(map.get("deviceType").toString()) == DictionaryEnums.DISCHARGE.getCode()) {
								DischargeRealdataBean dischargeRealdataBean = dischargeRealdataService
										.queryByDeviceNo(map.get("deviceNo").toString());

								if(dischargeRealdataBean!=null){
									noAlarm(map, null, dischargeRealdataBean, null, null);
								}
							}
							if (Integer.parseInt(map.get("deviceType").toString()) == DictionaryEnums.RAINWATER.getCode()) {
								RainwaterDischargeRealdataBean rainwaterDischargeRealdataBean = rainService
										.queryByDeviceNo(map.get("deviceNo").toString());
								if(rainwaterDischargeRealdataBean!=null){
									noAlarm(map, null, null, rainwaterDischargeRealdataBean, null);
								}
							}
							if (Integer.parseInt(map.get("deviceType").toString()) == DictionaryEnums.STORMWATER
									.getCode()) {
								PublicStormwaterRealdataBean publicStormwaterRealdataBean = publicService
										.queryByDeviceNo(map.get("deviceNo").toString());
								if(publicStormwaterRealdataBean!=null){
									noAlarm(map, null, null, null, publicStormwaterRealdataBean);
								}
							}
						} else {
							alarmBiz.sendMessage(map.get("deviceNo").toString(),
									Integer.parseInt(map.get("alarmType").toString()), DictionaryEnums.NO_ALARM);
						}
					}

				}
			}
		}catch (Exception e){
			LOG.error("TentNo" + ContextUtil.getTentNo()  ,e);
		}

				return  null;
	}

	public void noAlarm(Map<String, Object> map, IntakeRealdataBean intakeRealdataBean,
			DischargeRealdataBean dischargeRealdataBean, RainwaterDischargeRealdataBean rainwaterDischargeRealdataBean,
			PublicStormwaterRealdataBean publicStormwaterRealdataBean) {
		// 根据设备编号查询进水口的信息
		if (intakeRealdataBean != null) {
			if ("网络异常".equals(DictionaryEnums.find(Integer.parseInt(map.get("alarmType").toString())).getMsg())) {
				if (!"".equals(intakeRealdataBean.getNetwork()) && !"离线".equals(intakeRealdataBean.getNetwork())) {
					alarmBiz.sendMessage(map.get("deviceNo").toString(),
							Integer.parseInt(map.get("alarmType").toString()), DictionaryEnums.NO_ALARM);
				}
			}
			if ("电源异常".equals(DictionaryEnums.find(Integer.parseInt(map.get("alarmType").toString())).getMsg())) {
				if (!"".equals(intakeRealdataBean.getPowerSupply()) && !"异常".equals(intakeRealdataBean.getPowerSupply())) {
					alarmBiz.sendMessage(map.get("deviceNo").toString(),
							Integer.parseInt(map.get("alarmType").toString()), DictionaryEnums.NO_ALARM);
				}
			}
		}
		if (dischargeRealdataBean != null) {
			if ("网络异常".equals(DictionaryEnums.find(Integer.parseInt(map.get("alarmType").toString())).getMsg())) {
				
				if (!"".equals(dischargeRealdataBean.getNetwork()) && !"离线".equals(dischargeRealdataBean.getNetwork())) {
					alarmBiz.sendMessage(map.get("deviceNo").toString(),
							Integer.parseInt(map.get("alarmType").toString()), DictionaryEnums.NO_ALARM);
				}
			}
			if ("电源异常".equals(DictionaryEnums.find(Integer.parseInt(map.get("alarmType").toString())).getMsg())) {
				if (!"".equals(dischargeRealdataBean.getPowerSupply()) && !"异常".equals(dischargeRealdataBean.getPowerSupply())) {
					alarmBiz.sendMessage(map.get("deviceNo").toString(),
							Integer.parseInt(map.get("alarmType").toString()), DictionaryEnums.NO_ALARM);
				}
			}
			if ("监测房门开".equals(DictionaryEnums.find(Integer.parseInt(map.get("alarmType").toString())).getMsg())) {
				if (!"".equals(dischargeRealdataBean.getInstrument()) && !"开".equals(dischargeRealdataBean.getInstrument())) {
					alarmBiz.sendMessage(map.get("deviceNo").toString(),
							Integer.parseInt(map.get("alarmType").toString()), DictionaryEnums.NO_ALARM);
				}
			}
			if ("液位异常".equals(DictionaryEnums.find(Integer.parseInt(map.get("alarmType").toString())).getMsg())) {
				if (dischargeRealdataBean.getDrainLevel()!=null && !"".equals(dischargeRealdataBean.getDrainLevel()) && !"异常".equals(dischargeRealdataBean.getDrainLevel())) {
					alarmBiz.sendMessage(map.get("deviceNo").toString(),
							Integer.parseInt(map.get("alarmType").toString()), DictionaryEnums.NO_ALARM);
				}
			}
			if ("阀门故障".equals(DictionaryEnums.find(Integer.parseInt(map.get("alarmType").toString())).getMsg())) {
				if ((!"".equals(dischargeRealdataBean.getValveState()) && !"".equals(dischargeRealdataBean.getValveSetting()) && (Integer.parseInt(dischargeRealdataBean.getValveState())
						- Integer.parseInt(dischargeRealdataBean.getValveSetting())) > -10)
						&& ((Integer.parseInt(dischargeRealdataBean.getValveState())
								- Integer.parseInt(dischargeRealdataBean.getValveSetting())) < 10)) {
					alarmBiz.sendMessage(map.get("deviceNo").toString(),
							Integer.parseInt(map.get("alarmType").toString()), DictionaryEnums.NO_ALARM);
				}
			}
		}
		if (rainwaterDischargeRealdataBean != null) {
			if ("网络异常".equals(DictionaryEnums.find(Integer.parseInt(map.get("alarmType").toString())).getMsg())) {
				if (!"".equals(rainwaterDischargeRealdataBean.getNetwork()) && !"离线".equals(rainwaterDischargeRealdataBean.getNetwork())) {
					alarmBiz.sendMessage(map.get("deviceNo").toString(),
							Integer.parseInt(map.get("alarmType").toString()), DictionaryEnums.NO_ALARM);
				}
			}
			if ("电源异常".equals(DictionaryEnums.find(Integer.parseInt(map.get("alarmType").toString())).getMsg())) {
				if (!"".equals(rainwaterDischargeRealdataBean.getPowerSupply()) && !"异常".equals(rainwaterDischargeRealdataBean.getPowerSupply())) {
					alarmBiz.sendMessage(map.get("deviceNo").toString(),
							Integer.parseInt(map.get("alarmType").toString()), DictionaryEnums.NO_ALARM);
				}
			}
			if ("监测房门开".equals(DictionaryEnums.find(Integer.parseInt(map.get("alarmType").toString())).getMsg())) {
				if (!"".equals(rainwaterDischargeRealdataBean.getInstrument()) && !"开".equals(rainwaterDischargeRealdataBean.getInstrument())) {
					alarmBiz.sendMessage(map.get("deviceNo").toString(),
							Integer.parseInt(map.get("alarmType").toString()), DictionaryEnums.NO_ALARM);
				}
			}
			if ("液位异常".equals(DictionaryEnums.find(Integer.parseInt(map.get("alarmType").toString())).getMsg())) {
				if (!"".equals(rainwaterDischargeRealdataBean.getDrainLevel()) && !"异常".equals(rainwaterDischargeRealdataBean.getDrainLevel())) {
					alarmBiz.sendMessage(map.get("deviceNo").toString(),
							Integer.parseInt(map.get("alarmType").toString()), DictionaryEnums.NO_ALARM);
				}
			}
		}
		if (publicStormwaterRealdataBean != null) {
			if ("网络异常".equals(DictionaryEnums.find(Integer.parseInt(map.get("alarmType").toString())).getMsg())) {
				if (!"".equals(publicStormwaterRealdataBean.getNetwork()) && !"离线".equals(publicStormwaterRealdataBean.getNetwork())) {
					alarmBiz.sendMessage(map.get("deviceNo").toString(),
							Integer.parseInt(map.get("alarmType").toString()), DictionaryEnums.NO_ALARM);
				}
			}
			if ("电源异常".equals(DictionaryEnums.find(Integer.parseInt(map.get("alarmType").toString())).getMsg())) {
				if (!"".equals(publicStormwaterRealdataBean.getPowerSupply()) && !"异常".equals(publicStormwaterRealdataBean.getPowerSupply())) {
					alarmBiz.sendMessage(map.get("deviceNo").toString(),
							Integer.parseInt(map.get("alarmType").toString()), DictionaryEnums.NO_ALARM);
				}
			}
			if ("监测房门开".equals(DictionaryEnums.find(Integer.parseInt(map.get("alarmType").toString())).getMsg())) {
				if (!"".equals(publicStormwaterRealdataBean.getInstrument()) && !"开".equals(publicStormwaterRealdataBean.getInstrument())) {
					alarmBiz.sendMessage(map.get("deviceNo").toString(),
							Integer.parseInt(map.get("alarmType").toString()), DictionaryEnums.NO_ALARM);
				}
			}
		}
	}

	/**
	 * 自定义设备类型字符串转list
	 * 
	 * @return
	 */
	public static List<Integer> transferStringToList(String deviceType) {
		List<Integer> list = new ArrayList<Integer>();
		String[] deviceTypeArray = deviceType.split(",");
		for (int i = 0; i < deviceTypeArray.length; i++) {
			list.add(i, Integer.valueOf(deviceTypeArray[i]));
		}
		return list;
	}

	// 取水口
	public List<IntakeRealdataBean> selMapInRealData(Map<String, Object> maps) {
		/*
		 * IntakeRealdataService intakeRealdataService = (IntakeRealdataService)
		 * ContextUtil .getBean(IntakeRealdataService.class);
		 */
		List<IntakeRealdataBean> map = new ArrayList<IntakeRealdataBean>();
		map = intakeRealdataService.selectListByMap(maps);
		return map;
	}

	// 排放口
	public List<DischargeRealdataBean> selMapDrainInRealData(Map<String, Object> maps) {
		/*
		 * DischargeRealdataService dischargeRealdataService =
		 * (DischargeRealdataService) ContextUtil
		 * .getBean(DischargeRealdataService.class);
		 */
		List<DischargeRealdataBean> map = new ArrayList<DischargeRealdataBean>();
		map = dischargeRealdataService.selectListByMap(maps);
		return map;
	}

	// 企业雨水
	public List<RainwaterDischargeRealdataBean> selMapEnterpriseInRealData(Map<String, Object> maps) {
		/*
		 * RainwaterDischargeRealdataService rainService =
		 * (RainwaterDischargeRealdataService) ContextUtil
		 * .getBean(RainwaterDischargeRealdataService.class);
		 */
		List<RainwaterDischargeRealdataBean> map = new ArrayList<RainwaterDischargeRealdataBean>();
		map = rainService.selectListByMap(maps);
		return map;
	}

	// 公共雨水
	public List<PublicStormwaterRealdataBean> selMapPublicInRealData(Map<String, Object> maps) {
		/*
		 * PublicStormwaterRealdataService publicService =
		 * (PublicStormwaterRealdataService) ContextUtil
		 * .getBean(PublicStormwaterRealdataService.class);
		 */
		List<PublicStormwaterRealdataBean> map = new ArrayList<PublicStormwaterRealdataBean>();
		map = publicService.selectListByMap(maps);
		return map;
	}

	// 查询报警的设备和报警类型
	public List<Map<String, Object>> selAlarmWithAlarm(Map<String, Object> maps) {
		AlarmService alarmService = (AlarmService) ContextUtil.getBean(AlarmService.class);
		List<Map<String, Object>> list = alarmService.selStatusAlarm(maps);
		return list;
	}

	// 查询报警设置选中的报警类型，并将异常条件存入List
	public Map<String, Object> selTypeInSelect() {
		DictionaryService dictionaryService = (DictionaryService) ContextUtil.getBean(DictionaryService.class);
		List<Dictionary> dictionaryList = dictionaryService.selAlarmType();
		List<Integer> list = new ArrayList<Integer>();
		Map<String, Object> map = new HashMap<String, Object>();
		if (dictionaryList != null) {
			for (Dictionary dictionary : dictionaryList) {
				if ("阀门故障".equals(DictionaryEnums.find(dictionary.getDictionaryKey()).getMsg())) {
					map.put("valveSetting", "关");
					list.add(DictionaryEnums.VALVE_FAILURE.getCode());
				}
				if ("电源异常".equals(DictionaryEnums.find(dictionary.getDictionaryKey()).getMsg())) {
					map.put("powerSupply", "异常");
					list.add(DictionaryEnums.POWER_ANOMALY.getCode());
				}
				if ("网络异常".equals(DictionaryEnums.find(dictionary.getDictionaryKey()).getMsg())) {
					map.put("netWork", "离线");
					list.add(DictionaryEnums.NETWORK_OFFLINE.getCode());
				}
				if ("液位异常".equals(DictionaryEnums.find(dictionary.getDictionaryKey()).getMsg())) {
					map.put("drain", "异常");
					list.add(DictionaryEnums.LEVEL_ANOMALY.getCode());
				}
				if ("监测房门开".equals(DictionaryEnums.find(dictionary.getDictionaryKey()).getMsg())) {
					map.put("instrument", "开");
					list.add(DictionaryEnums.DOOR_OPEN.getCode());
				}
			}
		}
		map.put("list", list);
		return map;
	}

}
